import { Inject, Controller, Get } from "@midwayjs/core";
import { Context } from "@midwayjs/koa";
import { ApiTags } from "@midwayjs/swagger";
import { Utils } from "../utils/index";
import { WxService } from "../service/wx.service";

@ApiTags("测试controller")
@Controller()
export class TestController {
  @Inject()
  ctx: Context;

  @Inject()
  utils: Utils;

  @Inject()
  wxService: WxService;

  @Get("/auth-api/test/qrcode")
  async upload() {
    const scene = this.utils.snowFlake.generate();
    console.log("scene", scene);
    console.log("scene的长度", scene.length);
    const result = await this.wxService.getWxAppRewardCode(scene, "xyz");
    if (result.success) {
      return this.utils.response.success(result);
    } else {
      return this.utils.response.fail(result);
    }
  }
}
